package com.jprocms.module.cms.enums;

import com.google.common.collect.Lists;

import java.util.Arrays;
import java.util.List;

import static com.jprocms.module.cms.enums.EnumContentOperate.*;

/**
 * @author jprocms
 * 内容状态  1:已发布;   2:流转中;   3:待发布;  4:退回;  5:下线  6:草稿;   7 删除 8彻底删除 9归档
 */
public enum EnumContentStatus {
    DRAFT(6, "草稿", Lists.newArrayList(PREVIEW, SUBMIT_AUDIT, DELETE, MOVE, EDIT, PUBLISH, ARCHIVE)),
    AUDITING(2, "流转中", Lists.newArrayList(PREVIEW, REVOKE_AUDIT, AUDIT_PROCESS, EDIT)),
    AUDIT_FINISH(3, "待发布", Lists.newArrayList(PREVIEW, AUDIT_PROCESS, COPY, MOVE, EDIT, DELETE, PUBLISH, TOP, CANCEL_TOP, ARCHIVE)),
    AUDIT_FAILED(4, "退回", Lists.newArrayList(PREVIEW, SUBMIT_AUDIT, DELETE, MOVE, EDIT, PUBLISH, ARCHIVE)),
    PUBLISHED(1, "已发布", Lists.newArrayList(PREVIEW, BROWSE, AUDIT_PROCESS, QUOTE, MOVE, EDIT, DELETE, PUBLISH, COPY, TOP, CANCEL_TOP, OFF_LINE, ARCHIVE)),
    OFFLINE(5, "下线", Lists.newArrayList(PREVIEW, DELETE, MOVE, EDIT, PUBLISH, ARCHIVE)),
    DEL(7, "删除", Lists.newArrayList(DELETE_TWO, MOVE, EDIT, CREATE, ARCHIVE)),
    DEL_TWO(8, "彻底删除", Lists.newArrayList()),
    ARCHIVED(9, "归档", Lists.newArrayList(PREVIEW, CANCEL_ARCHIVE));


    private Integer status;
    private String desc;

    private List<EnumContentOperate> accessOps;

    EnumContentStatus(Integer status, String desc, List<EnumContentOperate> accessOps) {
        this.status = status;
        this.desc = desc;
        this.accessOps = accessOps;
    }

    public static EnumContentStatus getByStatus(Integer status) {
        return Arrays.stream(EnumContentStatus.values()).filter(item -> item.status.equals(status)).findFirst().orElse(null);
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public List<EnumContentOperate> getAccessOps() {
        return accessOps;
    }

    public void setAccessOps(List<EnumContentOperate> accessOps) {
        this.accessOps = accessOps;
    }
}
